#include "RemoteControl.h"

RemoteControl::RemoteControl()
{
    onCommands = new Command*[7];
    offCommands = new Command*[7];

    Command *noCommand = new NoCommand();

    for(int i = 0; i < 7; ++i) {
        onCommands[i]  = noCommand;
        offCommands[i] = noCommand;
    }
}

void RemoteControl::setCommand(int slot, Command *onCommand, Command *offCommand)
{
    onCommands[slot] = onCommand;
    offCommands[slot] = offCommand;
}

void RemoteControl::onButtonWasPushed(int slot)
{
    onCommands[slot]->execute();
}

void RemoteControl::offButtonWasPushed(int slot)
{
    offCommands[slot]->execute();
}

std::string RemoteControl::toString()
{
    string stringBuff;
    stringBuff.append("\n-------remote control-------\n");
    for(int i = 0; i < 1; ++i) {
        std::string slotStr = ("slot_" + to_string(i));
        std::string onCommandStr = onCommands[i]->getClassName();
        std::string offCommandStr = offCommands[i]->getClassName();
        stringBuff.append(slotStr);
        stringBuff.append(onCommandStr);
        stringBuff.append(offCommandStr);
    }
    return stringBuff;
}
